package it.abc.sicsic.view.backing;

import java.util.ArrayList;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import oracle.adf.view.rich.component.rich.data.RichTree;

import org.apache.myfaces.trinidad.model.ChildPropertyTreeModel;
import org.apache.myfaces.trinidad.model.TreeModel;

@ManagedBean(name = "backing_nauticaTemplate2")
@SessionScoped

public class NauticaTemplate2 {
    private Object instance = null;
    private transient TreeModel model = null;
    private ArrayList<NavigationItem> root;
    private RichTree tree;

    public NauticaTemplate2() {
        
        root = new ArrayList<NavigationItem>();
        
        NavigationItem clienti = new NavigationItem("Clienti", "clienti","true");
        NavigationItem barche = new NavigationItem("Barche", "barche","true");
        NavigationItem skipper = new NavigationItem("Skipper", "skipper","true");
        NavigationItem contratto = new NavigationItem("Contratto", "contratto","false");
        NavigationItem nautica = new NavigationItem("Nautica", "nautica","false");
        NavigationItem spese = new NavigationItem("Spese", "spese","false");        
        root.add(clienti);
        root.add(barche);
        root.add(skipper);
        root.add(contratto);        
        root.add(nautica);
        root.add(spese);

        ArrayList<NavigationItem> clientiChildren = new ArrayList<NavigationItem>();
        NavigationItem clientiInserisci = new NavigationItem("Inserisci", "inserisci","false");
        NavigationItem clinetiGestione = new NavigationItem("Gestione", "gestione","false");
        clientiChildren.add(clientiInserisci);
        clientiChildren.add(clinetiGestione);
        clienti.setChildren(clientiChildren);
        
        ArrayList<NavigationItem> barcheChildren = new ArrayList<NavigationItem>();
        NavigationItem barcheInserisci = new NavigationItem("Gestione", "gestione","false");
        NavigationItem barcheGestione = new NavigationItem("Gestione", "gestione","false");
        barcheChildren.add(barcheInserisci);
        barcheChildren.add(barcheGestione);
        barche.setChildren(barcheChildren);
        
        ArrayList<NavigationItem> skipperChildren = new ArrayList<NavigationItem>();
        NavigationItem skipperInserisci = new NavigationItem("Gestione", "gestione","false");
        NavigationItem skipperGestione = new NavigationItem("Gestione", "gestione","false");
        skipperChildren.add(skipperInserisci);
        skipperChildren.add(skipperGestione);
        skipper.setChildren(skipperChildren);
        
        setListInstance(root);
    }

    public TreeModel getModel() {
        if (model == null)
            model = new ChildPropertyTreeModel(instance, "children");
        return model;
    }

    public void setListInstance(List instance) {
        this.instance = instance;
        model = null;
    }

    public void setTree(RichTree tree) {
        this.tree = tree;
    }

    public RichTree getTree() {
        return tree;
    }
}
